<include file="Public/header" />
    <div class="comm-top">
        <div class="title-left">
	        <input value="导入车辆" id="sync_btn" class="btn btn-success search_btn" type="button">
	        <span style="font-size:12px;color:#aaa;font-weight:normal;">（注：因为单次同步有次数限制，若您发现未完全同步所有粉丝，您可以尝试多次同步）</span>
        </div>
        <div class="title-right" style="top:8px;">
        <form method="get" action="{:U('index')}">
            <input name="keywords" class="textarea search_inp" placeholder="请输入车辆编号或名称" type="text" value="{:I('get.keywords')}"/>
            <input value="搜索" class="btn btn-success search_btn" type="submit" />
            <input value="添加车辆" class="btn btn-success search_btn" type="button" onclick="add_form()" />
        </form>
        </div>
    </div>
    <div class="list-table">
        <div class="wrapper">
            <table class="stable">
                <thead>
                    <tr>
                        <th>车辆ID</th>
                        <th>车辆名称</th>
                        <th>颜色</th>
                        <th>车主姓名</th>
                        <th>车主手机号</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="list" item="vo">
                        <tr>
                            <td>{$vo.number|default='-无-'}</td>
                            <td>{$vo.name|default='-无-'}</td>
                            <td>{$vo.color|default='-无-'}</td>
                            <td>{$vo.user_name|default='-无-'}</td>
                            <td>{$vo.user_phone|default='-无-'}</td>
                            <if condition="$vo.status eq '1'">
                                <td class="staTd"><span>待售中</span></td>
                            <else />
                                <td class="staTd"><span class="staAct">已售出</span></td>
                            </if>
                            <td><div class="btn-operate">
                                <a href="javascript:void(0)" onclick="show_ewm('{$vo.id}')" title="查看二维码"><i class="glyphicon glyphicon-qrcode"></i></a>
                                <a href="javascript:void(0)" onclick="add_form('{$vo.id}')" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
                                <a href="javascript:void(0)" onclick="delRow('{$vo.id}',this)" title="删除" id="delBtn{$vo.id}"><i class="glyphicon glyphicon-trash"></i></a>
                            </div></td>
                        </tr>
                    </foreach>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page-list">{$page}</div>
    <include file="Public/dialog"/>
<script type="text/javascript">
//添加车辆弹框
function add_form(id){
	if(id == undefined || id == null){
		var url = "{:U('add')}";
		var dialog_title = '添加车辆';
	}else{
		var url = "{:U('add')}?id="+id;
		var dialog_title = '编辑车辆';
	}
	$.get(url,function(data){
		dialog(data,dialog_title,save);
	});
}
//展示二维码
function show_ewm(id){
	$.get("{:U('ewm')}?id="+id,function(data){
		dialog(data,'车辆二维码');
	});
}
//保存车辆信息
function save(event){
	var obj = event.target;
	$.post(
		"{:U('add')}",
		$('#dataForm').serializeArray(),
		function(data){
			if(data.status == '1'){
				note_info(data.info,obj);
				setTimeout("location.reload()",1000);
			}else{
				note_info(data.info,obj,'warn');
			}
		}
	);
}
//删除车辆
function delRow(id,obj){
    if(confirm('确定要删除吗？')){
        $.post("{:U('del')}",{id:id},function(res){
            if(res.status == 1){
                note_info(res.info,obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info(res.info,obj,'warn');
            }
        },'json');
    }
}
</script>
<include file="Public/footer" />